/*
 * Copyright 2010 Marcin Blazejewski
 *
 * This file is part of Nofate.
 *
 * Nofate is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Nofate is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nofate. If not, see <http://www.gnu.org/licenses/>.
 *
 */


#ifndef ATTRIBUTE_H_
#define ATTRIBUTE_H_

#include <list>
#include <string>

#define load_func_d(FUNC, CLASS) Attr* FUNC(const void **d)
#define load_func(FUNC, CLASS) Attr* FUNC(const void **d) { return new CLASS(d); }

class Attr {
 public:
    virtual ~Attr() {}

};

/*******************************************************************************/

class Aint : public Attr {
 public:
    int        value;

    Aint(const int v);
    Aint(const void **d);
    virtual ~Aint();
};


/*******************************************************************************/

class Afloat : public Attr {
 public:
    float       value;

    Afloat(const float v);
    Afloat(const void **d);
    virtual ~Afloat();
};


/*******************************************************************************/

class Astr : public Attr {
 public:
    std::string          value;

    Astr(const char *v);
    Astr(const void **d);
    virtual ~Astr();
};


/*******************************************************************************/

#define EQS_NONE           0
#define EQS_HAND           1
#define EQS_ARMOUR         2
#define EQS_PACK           3

class Acontainer : public Attr {
 public:
    int                       accept_slot;
    int                       size_capacity;
    int                       weight_capacity;

    std::list<class Thing*>   items;
    int                       size_used;
    int                       weight_used;
    
    Acontainer(int a, int s, int w);
    Acontainer(const void **d);
    virtual ~Acontainer();

    bool                      accepts(class Thing *t);
    void                      pickup(class Thing *itm, class Creature *cre);
    void                      drop(class Thing *itm, class Creature *cre);
};

Acontainer*                   con_find_target(class Creature *cre, class Thing *itm);


/*******************************************************************************/

class Aterrain : public Attr {
 public:
    int    bg;

    Aterrain(const int bg);
    Aterrain(const void **d);
    virtual ~Aterrain();
};


/*******************************************************************************/

load_func_d(atld_int, Aint);
load_func_d(atld_float, Afloat);
load_func_d(atld_str, Astr);
load_func_d(atld_container, Acontainer);
load_func_d(atld_terrain, Aterrain);


#endif
